function listProduct() {
    $.ajax({
        url : base + "/product/query_without_pager",
        data : $("#product_query_form").serialize(),
        dataType : "json",
        success : function(data) {
            var list_html = "<tr><th>ID</th><th>产品名称</th><th>产品价格(元)</th><th>产品类别</th><th>操作</th></tr>";
            for (var i = 0; i < data.list.length; i++) {
                var product = data.list[i];
                var tmp = "<tr><td>" + product.productId + "</td><td>" + product.productName +
                	"</td><td>" + product.money.amount + "</td><td>" + product.productType.typeName +
                	"</td><td><button type='button' class='btn btn-primary btn-sm' style='margin-right:30px;' " +
        			"onclick=\"location.href='" + base +"/jsp/product_add.jsp?id=" + product.productId + "'\">修改</button>" +
        			"<button type='button' class='btn btn-danger btn-sm' " +
        			"onclick='deleteProduct(" + product.productId + ");'>删除</button>" +
        			"</td></tr>";
                list_html += tmp;
            }
            $("#products").html(list_html);
        }
    });
}

function deleteProduct(productId) {
	if(confirm("是否删除？")) {
		$.ajax({
            url : base + "/product/delete",
            data : {"id":productId},
            dataType : "json",
            success : function (data) {
                if (data.ok) {
                	listProduct();
                } else {
                    alert(data.msg);
                }
            }
        });
	}
}